package com.zoe.wan.android.example.fragment.knowledge

import android.app.Application
import androidx.lifecycle.viewModelScope
import com.zoe.wan.android.example.repositry.Repository
import com.zoe.wan.android.example.repositry.data.knowledge.KnowledgeListData
import com.zoe.wan.android.example.repositry.data.knowledge.KnowledgeListDataItem
import com.zoe.wan.base.BaseViewModel
import com.zoe.wan.base.SingleLiveEvent
import kotlinx.coroutines.launch

class FragKnowledgeViewModel(application: Application) : BaseViewModel(application) {

    val knowledgeListData = SingleLiveEvent<List<KnowledgeListDataItem?>?>()

    init {

        getKnowledgeList()
    }

    fun getKnowledgeList() {
        viewModelScope.launch {
            val data = Repository.knowledgeList()
            data?.let {
                knowledgeListData.postValue(it)
            }
        }
    }


}